/**
 * @param {string} s
 * @param {string} a
 * @param {string} b
 * @param {number} k
 * @return {number[]}
 */
// 无法通过，应该是数据增加导致方法超时
var beautifulIndices = function (s, a, b, k) {
    let al = a.length, bl = b.length
    let candidateI = []
    let candidateJ = []
    let index = s.indexOf(a)
    while (index !== -1) {
        candidateI.push(index)
        index = s.indexOf(a, index + al)
    }
    index = s.indexOf(b)
    while (index !== -1) {
        candidateJ.push(index)
        index = s.indexOf(b, index + bl)
    }
    let ans = []
    for(let i = 0; i < candidateI.length; i++) {
        for(let j = 0; j < candidateJ.length; j++) {
            if(Math.abs(candidateI[i] - candidateJ[j]) <= k) {
                ans.push(candidateI[i])
                break
            }
        }
    }
    return ans
};
console.log(beautifulIndices("isawsquirrelnearmysquirrelhouseohmy", "my", "squirrel", 15));